<?php

class request extends xpfw {

    private $controller, $action;

    function __construct() {
        $uriComplete = explode('?', $_SERVER['REQUEST_URI']);
        $uriParts = explode('/', $uriComplete[0]);
        $cleanUriParts = array();


        foreach ($uriParts as $part)
            if (trim($part))
                $cleanUriParts[] = $part;

        $parts = count($cleanUriParts);
        switch ($parts) {
            case 2:
                $this->controller = $cleanUriParts[0] ? $cleanUriParts[0] : 'home';
                $this->action = $cleanUriParts[1] ? $cleanUriParts[1] : 'index';
                break;
            default:
                $this->controller = isset($cleanUriParts[0]) && $cleanUriParts[0] ? $cleanUriParts[0] : 'home';
                $this->action = 'index';
                break;
        }
    }

    public function getController() {
        return $this->controller;
    }

    public function setController($controller) {
        $this->controller = $controller;
    }

    public function getAction() {
        return $this->action;
    }

    public function setAction($action) {
        $this->action = $action;
    }

}

?>
